/**
	@author Thiago deMello Bueno
	@implementationNote This class is a Focus listener, which is passed a target and a delegate... when the focus is the target, it applies the delegate.
	@usage
	<code>
		var dg = mx.utils.Delegate.create(this,functionName);
		var selectionListener:SelectionListener = new SelectionListener(aTextField_txt,dg);
	</code>
*/
class timber.util.SelectionListener{
	
	private var focusTarget:Object;
	private var theDelegate:Object;
	
	function SelectionListener(mytarget:Object,mydelegate:Object){
		setDelegate(mydelegate);
		setFocusTarget(mytarget);
		Selection.addListener(this);
	}

	private function onSetFocus():Void{
		if(eval(Selection.getFocus()) == getFocusTarget()){
			theDelegate.apply(this,[this]);
		}
	}

	public function setDelegate(mydelegate:Object):Object{
		theDelegate = mydelegate;
		return theDelegate;
	}

	public function getDelegate():Object{
		return theDelegate;
	}
	
	public function setFocusTarget(mytarget:Object):Object{
		focusTarget = mytarget;
		return focusTarget;
	}
	
	public function getFocusTarget():Object{
		return focusTarget;
	}


}